<script type="text/javascript">
$(document).ready(function(){
        $(".entero").numeric(false);
        $(".decimal").numeric();
        $(".fecha").mask("99/99/9999");
 });
</script>

<div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">Registro de pago de cuotas</h4>
      </div>
      <?php 
      $nombre_controlador = 'cuotas';
      $metodo_guardar = 'guardar';
      $nombre_form = 'frm_cuotas';

      $attributes = array('class' => 'form-horizontal', 'role' => 'form', 'id' => $nombre_form);
      echo form_open($nombre_controlador . '/' . $metodo_guardar, $attributes); 
      ?>
      <div class="modal-body">
        <input type="hidden" name="txt_id_hist_plan" id="txt_id_hist_plan" value="<?=$historial_plan_id?>">

        <table class="table table-hover table-responsive">
          <?php
          if(isset($objCuota)) {
            if($objCuota->exists())
            {
              ?>
              <thead>
                <tr>
                  <td></td>
                  <td>Per&iacute;odo</td>
                  <td>Importe</td>
                  <td>Fecha de Cobro</td>
                </tr>
              </thead>
              <tbody>
              <?php
                foreach ($objCuota as $cuota)  
                {
                    $id_elemento = $cuota->id;
                    ?>

                    <tr>
                      <td><input type="checkbox" name="chk_cuotas[]" value="<?=$id_elemento?>"></td> 
                      <td><?=$cuota->periodo?></td> 
                      <td>
                        <?php 
                        $atributos = array('type' => 'number', 
                                           'class' => 'form-control decimal', 
                                           'name' => 'txt_importe_' . $id_elemento,
                                           'id' => 'txt_importe_' . $id_elemento, 
                                           'required' => 'required',
                                           'value' => $cuota->importe);
                        echo form_input($atributos);
                        ?>
                        </td> 
                      <td>
                        <?php 
                        $atributos = array('type' => 'text', 
                                           'class' => 'form-control fecha', 
                                           'name' => 'txt_fecha_cobro_' . $id_elemento,
                                           'id' => 'txt_fecha_cobro_' . $id_elemento,  
                                           'required' => 'required', 
                                           'value' => date('d/m/Y'));
                        echo form_input($atributos);
                        ?>
                      </td>
                    </tr>
                
              <?php 
              }
            }
            else { ?>
            <div class="alert alert-danger col-sm-offset-2 col-sm-8">No se encontraron cuotas pendientes</div>
            <?php
            }
          } 
          ?>
          </tbody>
        </table>        
      </div>
      <div class="modal-footer">
        <button type="submit" class="btn btn-default" >Guardar</button>
        <button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
      </div>
      <?php echo form_close();?>
  </div>
</div>